<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.List" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="entity.User" %>
<%@ page import="factory.DAOFactory" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>用户界面！</title>
</head>
<body>
 <center>
		<%
			if (session.getAttribute("user") != null) {
				List<User> list = DAOFactory.getIEmpDAOInstance().findall();
				User user=(User)session.getAttribute("user");
		%>
				<h4>你好,<%=user.getUsername()%></h4>
				<hr/>
				<h2>用户信息列表</h2>
				<table border="1" width="80%">
					<tr>
						<td align="center">ID</td>
						<td align="center">NAME</td>
						<td align="center">GENDER</td>
						<td align="center">AGE</td>
						<td align="center">EMAIL</td>
						<td align="center">REGDATETIME</td>
					</tr>
		<%
					for(int i = 0; i < list.size();i++){
						User u = list.get(i);
		%>
					<tr>
						<td align="center"><%=String.valueOf(u.getUserid())%></td>
      				    <td align="center"><%=u.getUsername()%></td>
      				    <td align="center"><%=u.getGender()%></td>
      			        <td align="center"><%=u.getAge()%></td>
       					<td align="center"><%=u.getEmail()%></td>
      				    <td align="center"><%=new SimpleDateFormat("yyyy-MM-dd").format(u.getRegdatetime())%></td>
					</tr>
		<% 
					}
		%>
				</table><br>
				<input type="button" value="修改个人信息" onclick="window.location='register.jsp'"/> 
				<input type="button" value="退出" onclick="window.location='login.jsp'"/>
		<%
			} else {
		%>
				<h1>请先登录!</h1>
				<hr />
				<h3>3秒后跳转到登录页面,如果没有跳转请点击<a href="login.jsp">这里</a>！</h3>
		<%
				response.setHeader("refresh", "3;URL=login.jsp");
			}
		%>
	</center>
</body>
</html>